package com.moli.iov.admin.websocket.service;

import com.moli.iov.admin.websocket.utils.MessageUtils;
import com.moli.iov.rest.RestResponse;
import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName AbstractWebSocketQueryService
 * @Description TODO
 * @Author 李伟松
 * @CreateDate 2019-03-12 下午 2:34
 * @UpdateDate 2019-03-12 下午 2:34
 * @Version 1.0
 */
@Slf4j
public abstract class AbstractWebSocketQueryService<T> implements WebSocketQueryService {

    public abstract T buildParam(String string) throws Exception;

    public abstract RestResponse get(T t,String token);

    @Override
    public final String query(String json,String token) {
        try {
            T t = buildParam(json);
            return MessageUtils.message(get(t,token));
        } catch (Exception e) {
            log.error("websocket查询异常",e.getMessage());
            e.printStackTrace();
        }
        return null;
    }
}
